import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { TestCase } from '../types'

export const useTestCaseStore = defineStore('testCase', () => {
  const cases = ref<TestCase[]>([])
  const loading = ref(false)

  const fetchCases = async () => {
    loading.value = true
    try {
      // TODO: 调用后端 API
      const response = await fetch('/api/cases')
      cases.value = await response.json()
    } catch (error) {
      console.error('获取用例失败:', error)
    } finally {
      loading.value = false
    }
  }

  return {
    cases,
    loading,
    fetchCases
  }
}) 